package com.zbkj.crmeb.merchant.admin.controller;


import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.crmeb.core.common.CommonResult;
import com.zbkj.crmeb.store.model.HomeActivity;
import com.zbkj.crmeb.store.model.Supplier;
import com.zbkj.crmeb.store.service.SupplierService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("api/admin/mer/store/supplier")
@Api(tags = "供应商服务")

public class MerSupplierController extends AdminBaseController {

    @Autowired
    private SupplierService supplierService;


    @ApiOperation(value = "获取所有供应商")
    @RequestMapping(value = "/getAllSupplier", method = RequestMethod.GET)
    public CommonResult<Object> getList(){
        return CommonResult.success(supplierService.list(Wrappers.<Supplier>lambdaQuery()
        		.eq(Supplier :: getIsDeleted, false)
        		.isNull(Supplier :: getMerId)
        		));
    }

    @ApiOperation(value = "获取云仓供应商")
    @RequestMapping(value = "/getCloudSupplier", method = RequestMethod.GET)
    public CommonResult<Object> getCloudSupplierList() {
        return CommonResult.success(supplierService.list(Wrappers.<Supplier>lambdaQuery()
                .eq(Supplier::getIsDeleted, false)
                .isNotNull(Supplier::getIsEurope)
        ));
    }

    @ApiOperation(value = "获取商户可见供应商")
    @GetMapping(value = "/getVisibleSupplier")
    public CommonResult<Object> getVisibleSupplier(HttpServletRequest servletRequest){
        return CommonResult.success(supplierService.getVisibleSupplier(getMerId(servletRequest)));
    }



}



